home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / Source / MSG Demo 1.4.source Folder / Demo ƒ / Fades ƒ / Circle serendipity fade.c < prev    next >
Text File  |  1994-04-15  |  2KB  |  74 lines

  1. /**********************************************************************\
  2.  
  3. File:        Circle serendipity fade.c
  4.  
  5. Purpose:    Graphic effect to fade main window to solid pattern.
  6.             See comments below for more description.
  7.  
  8. This program is free software; you can redistribute it and/or modify
  9. it under the terms of the GNU General Public License as published by
  10. the Free Software Foundation; either version 2 of the License, or
  11. (at your option) any later version.
  12.  
  13. This program is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. GNU General Public License for more details.
  17.  
  18. You should have received a copy of the GNU General Public License
  19. along with this program in a file named "GNU General Public License".
  20. If not, write to the Free Software Foundation, 675 Mass Ave,
  21. Cambridge, MA 02139, USA.
  22.  
  23. \**********************************************************************/
  24.  
  25. #include "timing.h"
  26.  
  27. #define CorrectTime 2
  28. #define theWindowHeight (boundsRect.bottom-boundsRect.top)
  29. #define theWindowWidth (boundsRect.right-boundsRect.left)
  30.  
  31. pascal short CircleSerendipityFade(Rect boundsRect, Pattern *thePattern);
  32.  
  33. /* I haven't the slightest idea why this works.  Hence the name.  -MP */
  34.  
  35. pascal short CircleSerendipityFade(Rect boundsRect, Pattern *thePattern)
  36. {
  37.     Rect            theRect;
  38.     RgnHandle        curregion, boundsRgn, sectrgn;
  39.     Point            zeropoint;
  40.     int                gap;
  41.     
  42.     gap=theWindowHeight/40;
  43.     SetRect(&theRect, boundsRect.left, boundsRect.top-2*theWindowHeight, boundsRect.right,
  44.         boundsRect.bottom-theWindowHeight);
  45.         
  46.     boundsRgn=NewRgn();
  47.     RectRgn(boundsRgn, &boundsRect);
  48.     sectrgn=NewRgn();
  49.     curregion=NewRgn();
  50.     SetEmptyRgn(curregion);
  51.     OpenRgn();
  52.         FrameOval(&theRect);
  53.     CloseRgn(curregion);
  54.     zeropoint.v=boundsRect.bottom;
  55.     zeropoint.h=boundsRect.left;
  56.     do
  57.     {
  58.         StartTiming();
  59.         SectRgn(curregion, boundsRgn, sectrgn);
  60.         FillRgn(sectrgn, *thePattern);
  61.         OffsetRgn(curregion, 0, gap);
  62.         TimeCorrection(CorrectTime);
  63.     }
  64.     while (!(PtInRgn(zeropoint, curregion)));
  65.  
  66.     FillRect(&boundsRect, *thePattern);
  67.     
  68.     DisposeRgn(curregion);
  69.     DisposeRgn(boundsRgn);
  70.     DisposeRgn(sectrgn);
  71.     
  72.     return 0;
  73. }
  74.